package com.junqson.je.admin.controller;

import com.junqson.je.admin.client.UserClient;
import com.junqson.je.admin.model.vo.UserAuthExamineResult;
import com.junqson.je.admin.service.UserService;
import com.junqson.je.common.model.ApiResult;
import com.junqson.je.common.model.dto.AuthInfoDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Descriptions
 * @Company
 * @Author Junqson
 * @Date 2020/2/3 12:14
 * @Version 1.0
 */
@RestController
public class UserController {

    @Autowired
    UserService userService;

    @Autowired
    UserClient userClient;

    /**
     * 创建认证工单
     * @param authInfoDTO
     * @return
     */

    @RequestMapping("/createUserAuthOrder")
    public ApiResult createUserAuthOrder(@RequestBody AuthInfoDTO authInfoDTO) {
        if (authInfoDTO == null) {
            return ApiResult.error("auth info vo is null!");
        }

        userService.createUserAuthOrder(authInfoDTO);
        return ApiResult.success();
    }


    /**
     * 查看未审核的认证工单
     *
     * @return
     */
    @RequestMapping("/waitExamineAuthOrders")
    public ApiResult examineUserAuthOrder() {
        return ApiResult.success(userService.getWaitExamineAuthOrders());
    }

    /**
     * 查看全部工单
     */
    @RequestMapping("/allAuthOrders")
    public ApiResult allAuthOrders() {
        return ApiResult.success(userService.getAllAuthOrders());
    }

    /**
     * 审核认证工单
     *
     * @return
     */
    @RequestMapping("/examineUserAuthOrder")
    public ApiResult examineUserAuthOrder(@RequestBody UserAuthExamineResult result) {
        if (result.getOrderId() == null) {
            return ApiResult.error("order id is null");
        }
        return userService.setUserAuthResult(result);
    }


}
